package com.naiterui.ehp.bs.doctor.controller;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.doctor.service.IPatientInquirerService;
import com.naiterui.ehp.bs.doctor.vo.patient.InquirerRelationVO;
import com.naiterui.ehp.bs.doctor.vo.patient.InquirerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 就诊人管理
 * @Author gongbaoqiang
 * @Date 2020/7/9 11:34 AM
 */
@Slf4j
@RestController
@RequestMapping("ad/patient/inquirer")
@Api(tags = {SwaggerTag.DOCTOR + SwaggerTag.PATIENT_INQUIRER})
public class AdPatientInquirerController {

    @Autowired
    private IPatientInquirerService inquirerService;

    /**
     * 就诊人列表: 只返回有过会话的就诊人
     * @param patientId
     * @return
     * @throws BusinessException
     */
    @ApiOperation(value = "就诊人列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "patientId", value = "患者id", dataType = "long", required = true, paramType = "query")
    })
    @PostMapping("list")
    public List<InquirerVO> list(Long patientId, Long doctorId) throws BusinessException {
        log.info("就诊人列表: patientId={}, doctorId={}", patientId, doctorId);
        return inquirerService.list(patientId, doctorId);
    }

    /**
     * 图文问诊就诊人详情
     * @param sessionId
     * @return
     * @throws BusinessException
     */
    @ApiOperation(value = "就诊人详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sessionId", value = "会话id", dataType = "string", required = true, paramType = "query")
    })
    @PostMapping("detail")
    public InquirerVO detail(String sessionId, Long patientId, Long doctorId) throws BusinessException {
        log.info("就诊人详情: sessionId={}, patientId={}, doctorId={}", sessionId, patientId, doctorId);
        return inquirerService.detail(sessionId, patientId, doctorId);
    }

    /**
     * 就诊人与患者关系：只返回有过会话的就诊人
     * @throws BusinessException
     */
    @ApiOperation("就诊人与患者关系列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "patientId", value = "患者id", dataType = "long", required = true, paramType = "query")
    })
    @PostMapping("relation/list")
    public List<InquirerRelationVO> relationList(Long patientId, Long doctorId) throws BusinessException{
        log.info("就诊人与患者关系: patientId={}, doctorId={}", patientId, doctorId);
        return inquirerService.relationList(patientId, doctorId);
    }
}
